package top.cwk.dubbo.entity.util;

import java.io.*;

/**
 * @ClassName BaseUtils
 * @Description TODO
 * @Author 维康
 * @Date 2018/7/26 17:07
 * @Version 1.0
 **/
public class BaseUtils {


    static public String readFileContent(String filePath){
        File file = new File(filePath);
        return readFileContent(file,"UTF-8");
    }
    static public String readFileContent(File file){
        return readFileContent(file,"UTF-8");
    }
    static public String readFileContent(File file , String encoding){
        Long filelength = file.length();
        byte[] filecontent = new byte[filelength.intValue()];
        try {
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            return new String(filecontent, encoding);
        } catch (UnsupportedEncodingException e) {
            System.err.println("The OS does not support " + encoding);
        }
        return "";
    }

}
